<?php
class category_model extends CI_Model
{
    protected $_table = "mock_categories";
    public function listCate_move($parent){
        $this->db->where("cate_parent",$parent);
        return $this->db->get($this->_table)->result_array();
    }
    public function listCate(){
        return $this->db->get($this->_table)->result_array();
    }
    public function totalCate()
    {
        return $this->db->count_all($this->_table);
    }

    public function update($id,$data){
        $this->db->where("cate_id",$id);
        $this->db->update($this->_table,$data);
    }
    public function getdata($id){
        $this->db->where("cate_id",$id);
        return $this->db->get($this->_table)->row_array();
    }
    public function listCate_product(){
        return $this->db->get($this->_table)->result_array();
    }

    public function checkCate($field,$data,$id=''){
        if($id != ''){
            $this->db->where('cate_id !=',$id);
        }
        $this->db->where($field,$data);
        $numrows = $this->db->count_all_results($this->_table);
        if($numrows >0){
            return FALSE;
        }else{
            return TRUE;
        }
    }
    public function cate_move($id){
        if($id != ''){
            $this->db->where('cate_id !=',$id);
        }
        return $this->db->get($this->_table)->result_array();
    }
}